/**
 * Bakalarska prace - Inteligentni budik
 * @package sleepCatcher
 * @file FormAlarm.h
 * @author Jan Pesava - xpesav00
 * @email xpesav00@stud.fit.vutbr.cz
 * @date 24. 12. 2011
 */

#ifndef FORMALARM_H_
#define FORMALARM_H_

#include <FBase.h>
#include <FUi.h>
#include <FGrpRectangle.h>

#include "SCFormManager.h"

using namespace Osp::Base;
using namespace Osp::Base::Collection;
using namespace Osp::Ui::Controls;
using namespace Osp::Ui;
using namespace Osp::Graphics;



class FormAlarm  :
	public Osp::Ui::Controls::Form,
	public Osp::Ui::IActionEventListener,
	public Osp::Ui::Controls::IListViewItemEventListener,
	public Osp::Ui::Controls::IListViewItemProvider
{

// Construction
public:
	FormAlarm();
	virtual ~FormAlarm();

// Constants
public:
	static const RequestId IDA_OPTION_MENU 	= 200;
	static const int LIST_ITEM_NAME 		= 201;
	static const int LIST_ITEM_TIME			= 202;
	static const int LIST_ITEM_REPEAT		= 203;

// Attributes
private:
	ArrayList *pAlarmsList;
	ListView *pListView;


// Methods
public:
	bool Initialize(void);
	virtual result OnInitializing(void);
	virtual result OnTerminating(void);
	virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
	virtual void OnListViewContextItemStateChanged (Osp::Ui::Controls::ListView &listView, int index, int elementId, Osp::Ui::Controls::ListContextItemStatus status);
	virtual void OnListViewItemLongPressed (Osp::Ui::Controls::ListView &listView, int index, int elementId, bool &invokeListViewItemCallback);
	virtual void OnListViewItemStateChanged (Osp::Ui::Controls::ListView &listView, int index, int elementId, Osp::Ui::Controls::ListItemStatus status);
	virtual void OnListViewItemSwept (Osp::Ui::Controls::ListView &listView, int index, Osp::Ui::Controls::SweepDirection direction);
	virtual Osp::Ui::Controls::ListItemBase* CreateItem(int index, int itemWidth);
	virtual bool DeleteItem(int index, Osp::Ui::Controls::ListItemBase* pItem, int itemWidth);
	virtual int GetItemCount(void);
	int GetFormId();
	void SetItemChecked(int index, bool check);
	void Update();
	void Redraw();
	virtual result OnDraw();
private:
	void SetAlarms(ArrayList* pList);
	ArrayList* GetAlarms();
	void SetAlarmsFromDB();
};

#endif /* FORMALARM_H_ */
